/**
 * Class containing the look up table strategy.
 * @author	081028AW
 */
public class StrategyLookUpTableFinal extends Strategy
   {
  /**
   * Encoding for LookUpTable strategy.
   */
   int opponent2ndLastMove = 0;
   int my2ndLastMove = 0;
   int moveNum;
   public String simpleStratMoves = "0010001001010100";
   int currMove;
   public String simpleStrat;

  // 0 = defect, 1 = cooperate

   public StrategyLookUpTableFinal()
	{
		name = "2Moves";
		currMove = 0;
	} 
   
   public void saveOpponentMove(int move)  
   { 
	   opponent2ndLastMove = opponentLastMove;
	   opponentLastMove = move; 
   }
   
   public void saveMyMove(int move)  
   {
	   my2ndLastMove = myLastMove; 
	   myLastMove = move;
   }
   

   public int nextMove()
   {

	   //assuming bit string of 2^4 = 16
	   int location = 0;
	   
	   location = (int) Math.pow(2 , 0) * opponentLastMove;
	   location = location + (int) Math.pow(2, 1) * opponent2ndLastMove;
	   location = location + (int) Math.pow(2, 2) * myLastMove;
	   location = location + (int) Math.pow(2, 3) * my2ndLastMove;
	   
	   return Character.digit(simpleStratMoves.charAt(location), 10);

   }  /* nextMove */

   }

